

import java.math.*;
import java.util.HashMap;
import java.lang.reflect.Field;

public class Reactor extends SplitSimSystem{
	private double upperLimit;
	private double lowerLimit;
	private double temp=startPar;
	private double moistureContent=10;
	private int leakageFactor=0;
	HashMap<String,Double> state = new HashMap<String,Double>();
	
	public void Reactor1(){
		System.out.println("here");
		setStartPar(300.0);
		setMaxPar(400.0);System.exit(1);
		//state.put("temp",temp);
		//state.put("moistureContent",moistureContent);
	}
	
	public void initialize(double upperLimitInput, double lowerLimitInput, double tempInput){
		upperLimit=upperLimitInput;
		lowerLimit=lowerLimitInput;
		temp=tempInput;
		super.poi=temp;
		setStartPar(300.0);
		setMaxPar(400.0);
	}
	
	public boolean run(){
		//leakageFactor
		for (int runCount=0; runCount<100000;runCount++){
			leakageFactor = (int)(Math.random()*1000);
			//System.out.println(leakageFactor);
			double oldMoistureContent=moistureContent;
			//System.out.println(leakageFactor);
			//System.out.println(runCount+"--");
			if (leakageFactor>=999){
				moistureContent++;
			}
			if (leakageFactor<500){
				moistureContent--;
			}
			//System.out.println(moistureContent);
			//moisture to temperature correlation
			if (moistureContent!=oldMoistureContent && temp<390){
				temp = temp * 1.11*moistureContent/oldMoistureContent;
			}
			//moisture to temperature correlation
			else if (moistureContent!=oldMoistureContent && temp>=390){
				temp = temp * 1.11*moistureContent/oldMoistureContent;
			}
			
			syncLevel();
			
			super.poi=temp;
			
			//System.out.println("moistureContent="+moistureContent+"----");
			//System.out.println("temp="+temp+"----");
			//hit fail determination
			if (temp>=upperLimit){
				return true;
			}
			else if (temp<lowerLimit){
				return false;
			}
			
		}
		return false;
	}
	

}
